
<%@ page import="gfo.Fighter" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'fighter.label', default: 'Fighter')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
    </head>
    <body>
    <div class="body">
        <h1>${fighterInstance.name}</h1>
        See the <a href="http://www.ssbwiki.com/${fighterInstance.name}_(SSBB)">Smash wiki</a> for more info.
        <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
        </g:if>
    <!--Descriptions here-->

    <!--Nothing fancy here--just making use of the mostWonBy and MostPlayedBy methods for Fighter.
    You may also notice that each Fighter has the same picture (and it's a picture of a stage...)--
    this is because I have yet to specify a 'picFilename' attribute for Fighter.-->
        <div class="dialog">
            <table>
                <tbody>

                <tr class="prop">
                    <td valign="top" class="name">
                        ${fighterInstance.name}
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">
                        <img src="/GFO/images/gf_res/${fighterInstance.name.toLowerCase()}.jpg"
                             alt="${fighterInstance.name}" title="${fighterInstance.name}" border="0" />
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Description</td>
                    <td valign="top" class="value">
                        ${fighterInstance.description}
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Most Played By:</td>
                    <td valign="top" class="value">
                        <g:set var="mPB" value="${fighterInstance.mostPlayedBy()}"></g:set>
                        <g:if test="${mPB}">
                            <g:link controller="player" action="show" id="${mPB?.id}">
                                ${fighterInstance.mostPlayedBy()?.fullName.encodeAsHTML()}
                            </g:link>
                        </g:if>
                        <g:else>
                            NA
                        </g:else>
                    </td>
                </tr>

                <tr class="prop">
                    <td valign="top" class="name">Most Won By:</td>
                    <td valign="top" class="value">
                        <g:set var="mWB" value="${fighterInstance.mostWonBy()}"></g:set>
                        <g:if test="${mWB}">
                            <g:link controller="player" action="show" id="${mWB?.id}">
                                ${fighterInstance.mostWonBy()?.fullName.encodeAsHTML()}
                            </g:link>
                        </g:if>
                        <g:else>
                            NA
                        </g:else>
                    </td>
                </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="fighter.matches.label" default="Matches" /></td>
                            
                            <td valign="top" style="text-align: left;" class="value">
                                <ul>
                                <g:each in="${fighterInstance.matches}" var="m">
                                    <li><g:link controller="match" action="show" id="${m.match.id}">${m?.match.encodeAsHTML()}</g:link></li>
                                </g:each>
                                </ul>
                            </td>
                            
                        </tr>
                    
                    </tbody>
                </table>
            </div>
            <div class="buttons">
                <g:form>
                    <g:hiddenField name="id" value="${fighterInstance?.id}" />
                    <!--Don't want edit in its natural sense, but rather, for descriptive
                        purposes, e.g. trivia-->
                    <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </g:form>
            </div>
        </div>
    </body>
</html>
